package com.ymatou.iapi.csim.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.csim.parameter.OffLineCallBackBean;
import com.ymatou.iapi.csim.service.OffLineCallBackCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CsimCallService;
import com.ymttest.database.model.ymt_onlinecs;
import com.ymttest.database.sqlwapper.CSIM.ymt_onlinecsWapper;
import com.ymttest.utils.EnvSetup;
/**
*网络不正常时回调接口
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_OffLineCallBack{
	private static OffLineCallBackBean bean;
	private static OffLineCallBackCall call;
	private CsimCallService service=new CsimCallService();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("网络不正常时回调接口");
	}

	@Before
	public void caseUp() {
		bean=new OffLineCallBackBean();
		call=new OffLineCallBackCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_OffLineCallBack_001() {
		Logger.start(true,"网络不正常时回调接口-正常退出");
		try {
			ymt_onlinecs onlinecs1 =service.getOnlineCS();
			bean.setOffLineType(1);//下线类型(1：正常退出 2：浏览器关闭 3：客户端超时)
			bean.setSocketIoToken(onlinecs1.getSocketIoToken());//	socket标识
			call.setData(bean);
			call.callService();					
			Logger.verifyEquals("ok", call.getReturnData(), "验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_OffLineCallBack_002() {
		Logger.start(true,"网络不正常时回调接口-浏览器关闭");
		try {
			ymt_onlinecs onlinecs1 =service.getOnlineCS();
			bean.setOffLineType(2);//下线类型(1：正常退出 2：浏览器关闭 3：客户端超时)
			bean.setSocketIoToken(onlinecs1.getSocketIoToken());//	socket标识
			call.setData(bean);
			call.callService();					
			Logger.verifyEquals("ok", call.getReturnData(), "验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_OffLineCallBack_003() {
		Logger.start(true,"网络不正常时回调接口-客户端超时");
		try {
			ymt_onlinecs onlinecs1 =service.getOnlineCS();
			bean.setOffLineType(3);//下线类型(1：正常退出 2：浏览器关闭 3：客户端超时)
			bean.setSocketIoToken(onlinecs1.getSocketIoToken());//	socket标识
			call.setData(bean);
			call.callService();					
			Logger.verifyEquals("ok", call.getReturnData(), "验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}